import request from '../request.ts'

// 课程管理API

// 获取课程列表
export const getCourses = (params) => {
  return request({
    url: '/courses',
    method: 'get',
    params
  })
}

// 创建课程
export const createCourse = (data) => {
  return request({
    url: '/courses',
    method: 'post',
    data
  })
}

// 更新课程
export const updateCourse = (id, data) => {
  return request({
    url: `/courses/${id}`,
    method: 'put',
    data
  })
}

// 删除课程
export const deleteCourse = (id) => {
  return request({
    url: `/courses/${id}`,
    method: 'delete'
  })
}

// 获取课程详情
export const getCourseById = (id) => {
  return request({
    url: `/courses/${id}`,
    method: 'get'
  })
}

// 教师课程关联管理

// 获取课程的教师列表
export const getCourseTeachers = (courseId) => {
  return request({
    url: `/courses/${courseId}/teachers`,
    method: 'get'
  })
}

// 为课程分配教师
export const assignTeacherToCourse = (courseId, teacherId) => {
  return request({
    url: `/courses/${courseId}/teachers`,
    method: 'post',
    data: { teacherId }
  })
}

// 从课程中移除教师
export const removeTeacherFromCourse = (courseId, teacherId) => {
  return request({
    url: `/courses/${courseId}/teachers/${teacherId}`,
    method: 'delete'
  })
}

// 获取教师的课程列表
export const getTeacherCourses = (teacherId) => {
  return request({
    url: `/course-management/teachers/${teacherId}/courses`,
    method: 'get'
  })
}

// 批量分配教师到课程
export const batchAssignTeachers = (courseId, teacherIds) => {
  return request({
    url: `/courses/${courseId}/teachers/batch`,
    method: 'post',
    data: { teacherIds }
  })
}